package cn.tedu.online.day10.stream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileStreamDemo {
    public static void main(String[] args) throws IOException {
        //按照单个字节进行复制
        //创建输入输出流
        FileInputStream fis = new FileInputStream("DeleteList.java");
        FileOutputStream fos = new FileOutputStream("copy2.txt");
        //先读后写进行复制
//        int by=-1;  //表示接收读取到的字节
//        while ((by=fis.read())!=-1){
//            fos.write(by);
//        }

        //按照字节数组复制
        byte[] bys = new byte[100];
        int len=-1;
        while ((len=fis.read(bys))!=-1){
            fos.write(bys,0,len);
        }

        //关闭流资源
        fos.close();
        fis.close();
    }
}
